// run: $exec < input
#include <iostream>

struct data
{
	int x1, x2, y1, y2;
	int id;
};

data da[20];
int n, m;

bool inrange(int x, int y, int id)
{
	return da[id].x1 <= x && x <= da[id].x2 && da[id].y1 <= y && y <= da[id].y2;
}

int main()
{
	std::ios::sync_with_stdio(false);
	while (std::cin >> n >> m) {
		for (int i = n; i >= 1; i--) {
			std::cin >> da[i].x1 >> da[i].y1 >> da[i].x2 >> da[i].y2;
			da[i].id = n - i + 1;
		}
		for (int i = 0; i < m; i++) {
			int x, y; std::cin >> x >> y;
			bool ignore = true;
			for (int j = 1; j <= n; j++) {
				if (inrange(x, y, j)) {
					ignore = false;
					std::cout << da[j].id << "\n";
					data tmp = da[j];
					for (int k = j - 1; k >= 1; k--)
						da[k + 1] = da[k];
					da[1] = tmp;
					break;
				}
			}
			if (ignore) std::cout << "IGNORED\n";
		}
	}
}

